function formatDate(date, format) {
    const replacements = {
        YYYY: date.getFullYear(),
        MM: String(date.getMonth() + 1).padStart(2, '0'),
        DD: String(date.getDate()).padStart(2, '0'),
        HH: String(date.getHours()).padStart(2, '0'),
        mm: String(date.getMinutes()).padStart(2, '0'),
        ss: String(date.getSeconds()).padStart(2, '0')
    };
    return Object.entries(replacements).reduce(
        (str, [key, value]) => str.replace(key, value),
        format
    );
}

export function getCurrentDate(format = 'YYYY-MM-DD') {
    return formatDate(new Date(), format);
}

export function getDateSevenDaysAgo(format = 'YYYY-MM-DD') {
    const date = new Date();
    date.setDate(date.getDate() - 7);
    return formatDate(date, format);
}

